import request from "@/request/index";
import { typeHosListByPageContent, typeBookingRule } from "@/api/home";

//请求1：根据医院编号 获取医院预约挂号详情
export const reqHosDetailByHosname = (hoscode: string) => {
  return request.get<any, typeHosDetailByHosname>(`/hosp/hospital/${hoscode}`);
};

//类型1:医院预约挂号详情返回值类型
export interface typeHosDetailByHosname {
  bookingRule: typeBookingRule;
  hospital: typeHosListByPageContent;
}

//请求2：根据医院编号 获取医院科室列表
export const reqHosDepartmentList = (hoscode: string) => {
  return request.get<any, typeHosDepartmentListResponse>(
    `/hosp/hospital/department/${hoscode}`
  );
};
//类型2：医院科室列表 返回值类型
export type typeHosDepartmentListResponse = typeEachDepartment[];

//2-1单项科室类型
export interface typeEachDepartment {
  depcode: string;
  depname: string;
  children: typeClinic[];
}
//2-2科室详细门诊类型
export interface typeClinic {
  depcode: string;
  depname: string;
  children: null;
}

//请求3:获取科室排班规则数据
export const reqGetScheduleRule = (
  page: number,
  limit: number,
  hoscode: string,
  depcode: string
) => {
  return request.get<any,typeGetScheduleRule>(
    `/hosp/hospital/auth/getBookingScheduleRule/${page}/${limit}/${hoscode}/${depcode}`
  );
};
//类型3:返回值类型
export interface typeGetScheduleRule {
  total: number;
  bookingScheduleList: [
    {
      workDate: string;
      workDateMd: null;
      dayOfWeek: string;
      docCount: number;
      reservedNumber: number;
      availableNumber: number;
      status: null;
    }
    
  ];
  baseMap: {
    hosname: string;
  };
}

//请求4:获取排班数据(获取每天号源)
export const reqFindScheduleList = (
  hoscode: string,
  depcode: string,
  workDate: string
) => {
  return request.get<any,typeFindSchedule[]>(
    `/hosp/hospital/auth/findScheduleList/${hoscode}/${depcode}/${workDate}`
  );
};
//类型4:返回值类型
export interface typeFindSchedule {
    id: string,
    createTime: string,
    updateTime: string,
    isDeleted: number,
    param: {
      dayOfWeek: string,
      depname: string,
      hosname: string,
    },
    hoscode: string,
    depcode: string,
    title: string,
    docname: string,
    skill: string,
    workDate: string,
    workTime: number,
    reservedNumber: number,
    availableNumber: number,
    amount: number,
    status: number,
    hosScheduleId: string,
  }
  
  
  //请求5:创建订单
  export const submitOrder = (hoscode:string,scheduleId:string,patientId:string) =>{
    return request.post(`/order/orderInfo/auth/submitOrder/${hoscode}/${scheduleId}/${patientId}`)
  }

